package test2.table;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.IndexedColors;

import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;

import test2.pojo.Se;
import test2.pojo.SeSubject;
import utils.WishColumn;
import utils.WishExcel;
import utils.WishModule;

/**
 * 1个sheet多个table
 * @author maml
 */
public class TableTest
{
	public static void main(String[] args)
	{
		WishModule<Se> wishWriteTable1 = new WishModule<>("sheet1");
		{
			List<WishColumn<?>> headers = new ArrayList<>();
			WishColumn<?> all = new WishColumn<>("整体考试情况分析");
			headers.add(all);

			WishColumn<Se> header1 = new WishColumn<>("姓名1", 20, x -> x.getName());
			WishColumn<Se> header2 = new WishColumn<>("年龄1", 60, x -> 12);
			all.setChildren(Arrays.asList(header1, header2));
			wishWriteTable1.setTableHeaders(headers);
			wishWriteTable1.setDatasSupplier(() -> {
				List<Se> datas = new ArrayList<>();
				Se a = new Se();
				a.setAge(18);
				a.setName("maml");
				datas.add(a);
				Se b = new Se();
				b.setAge(19);
				b.setName("wangmia");
				datas.add(b);
				return datas;
			});
			// wishWriteTable1.setMerges(Arrays.asList(new int[] { 1, 2, 0, 0 }));
		}

		WishModule<SeSubject> wishWriteTable2 = new WishModule<>();
		{
			List<WishColumn<?>> headers = new ArrayList<>();
			WishColumn<SeSubject> header1 = new WishColumn<>("姓名1",x -> x.getId());
			WishColumn<SeSubject> header2 = new WishColumn<>("年龄1", x -> x.getName());
			headers.add(header1);
			headers.add(header2);
			wishWriteTable2.setTableHeaders(headers);
			wishWriteTable2.setDatasSupplier(() -> {
				List<SeSubject> datas = new ArrayList<>();
				SeSubject a = new SeSubject();
				a.setId(18l);
				a.setName("aaa");
				datas.add(a);

				SeSubject b = new SeSubject();
				b.setId(19);
				b.setName("aaaaaaaa");
				datas.add(b);
				return datas;
			});
			// wishWriteTable2.setMerges(Arrays.asList(new int[] { 1, 2, 0, 0 }));
		}

		WishExcel.write("test.xlsx", "教师和学生信息", Arrays.asList(wishWriteTable1, wishWriteTable2));
	}
}
